package my.graduation.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import my.graduation.dto.PatExamScheDto;
import my.graduation.entity.ExaminationSpots;
import my.graduation.entity.RegistrationSpots;
import my.graduation.enums.HttpCodeEnums;
import my.graduation.mapper.ExaminationSpotsMapper;
import my.graduation.mapper.RegistrationSpotsMapper;
import my.graduation.result.Result;
import my.graduation.service.ExaminationSpotsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: RavenLyn
 * @Date: 2025-02-26
 */
@Service
public class ExaminationSpotsServiceImpl extends ServiceImpl<ExaminationSpotsMapper, ExaminationSpots> implements ExaminationSpotsService {

    @Autowired
    private ExaminationSpotsMapper examSpotsMapper;

    /**
     * 根据examScheId获取医生检查预约号源
     * @param dto
     * @return
     */
    @Override
    public Result<List<ExaminationSpots>> patientGetExamSpotsList(PatExamScheDto dto) {
        if(dto.getExamScheId() != null){
            List<ExaminationSpots> list = list(Wrappers.<ExaminationSpots>lambdaQuery().eq(ExaminationSpots::getExamScheId, dto.getExamScheId()));
            return Result.success(list);
        }else {
            return Result.error(HttpCodeEnums.SYSTEM_ERROR);
        }
    }

    /**
     * 患者-占号
     * @param examSpotsId
     * @return
     */
    @Override
    public Boolean gainOne(Integer examSpotsId) {
        return examSpotsMapper.gainOne(examSpotsId);
    }

    /**
     * 患者-还号
     * @param examSpotsId
     * @return
     */
    @Override
    public Boolean returnOne(Integer examSpotsId) {
        return examSpotsMapper.returnOne(examSpotsId);
    }
}
